package com.pig4cloud.pig.module.api.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.pig4cloud.pig.admin.api.entity.SysDept;
import com.pig4cloud.pig.admin.api.entity.SysMenu;
import com.pig4cloud.pig.module.api.entity.platform.PlatformHelp;
import com.pig4cloud.pig.module.api.entity.product.ProductType;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 *
 * @author mr.zhou
 */
@Data
public class TreeSelect implements Serializable {
	private static final long serialVersionUID = 1L;

	/** 节点ID */
	private Integer id;

	/** 节点名称 */
	private String label;

	/** 子节点 */
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	private List<TreeSelect> children;

//	public TreeSelect(SysDept dept)
//	{
//		this.id = dept.getDeptId();
//		this.label = dept.getDeptName();
//		this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
//	}
//
//	public TreeSelect(SysMenu menu)
//	{
//		this.id = menu.getMenuId();
//		this.label = menu.getMenuName();
//		this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
//	}
//
	public TreeSelect(ProductType type)
	{
		this.id = type.getId();
		this.label = type.getTypeName();
		this.children = type.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
	}

	public TreeSelect(PlatformHelp help)
	{
		this.id = help.getId();
		this.label = help.getTitle();
		this.children = help.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
	}
}
